//
//  main.cpp
//  移动赋值运算
//
//  Created by huangj on 2018/7/16.
//  Copyright © 2018年 中恒云能源. All rights reserved.
//

#include <iostream>

using namespace std;

class MyString {
    private :
    char* Buffer;
    MyString(): Buffer(NULL){
        cout << "Default constructor called" << endl;
    }
    
public:
    ~MyString(){
        if (Buffer != NULL) {
            delete [] Buffer;
        }
    }
    
    int GetLength(){
        return strlen(Buffer);
    }
    operator const char *(){
        return Buffer;
    }
    
    MyString operator + (const MyString& addThis){
        cout << "opreator+ called: " << endl;
        MyString newString;
        if (addThis.Buffer != NULL) {
            newString.Buffer = new char [GetLength() + strlen(addThis.Buffer)];
            strcpy(newString.Buffer,Buffer);
            strcat(newString.Buffer, addThis.Buffer);
        }
        return newString;
    }
    
    MyString
    
    
};

int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}
